<?php use_stylesheet('bootstrap.min.css') ?>
<?php use_stylesheet('bootstrap-responsive.min.css') ?>
<?php use_javascript('bootstrap.min.js') ?>
<?php include_partial('global/flashes') ?>
<?php
$timediff = 0;
if (date('w') == 5 || date('w') == 6) {
    $timediff = 244800;
} else {
    $timediff = 158400;
}
?>
<div id="sf_admin_container" class="container-fluid well">
    <div id="sf_admin_content" class="row-fluid">
        <div class="span12">
            <form method="post" action="<?php echo url_for('alumno/examenes?id=' . $sf_request->getParameter('id')) ?>">
                <div class="sf_admin_form">
                    <table class="table-condensed table-striped table-bordered table">
                        <thead>
                            <tr>
                                <th></th>
                                <th>Nro.</th>
                                <th>Unidad Curricular</th>
                                <th>Fecha y Hora</th>
                                <th>Condición</th>
                                <th>Ausente</th>
                                <th>Pagado</th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($examenes_alumno as $examen_alumno): ?>
                            <?php $timestamp = date('Y-m-d H:i:s', strtotime(date('Y-m-d', strtotime($examen_alumno->getExamen()->getFecha())).' '.date('H:i:s', strtotime($examen_alumno->getExamen()->getHora())))) ?>
                                <tr <?php if(strtotime($timestamp) - time() < $timediff): ?>class="error"<?php endif ?>>
                                    <td><input type="checkbox" name="examen_alumno[<?php echo $examen_alumno->getId() ?>][imprimir]" id="examen_alumno_<?php echo $examen_alumno->getId() ?>" /></td>
                                    <td><?php echo $examen_alumno->getNumeroPermiso() ?></td>
                                    <td><?php echo $examen_alumno->getExamen()->getModulo()->getNombre() ?></td>
                                    <td><?php echo date('d/m/Y', strtotime($examen_alumno->getExamen()->getFecha())) . ' ' . date('H:i:s', strtotime($examen_alumno->getExamen()->getHora())) ?> hs</td>
                                    <td>
                                        <select class="condensed" name="examen_alumno[<?php echo $examen_alumno->getId() ?>][condicion]">
                                            <?php
                                            foreach ($condiciones as $value => $condicion) {
                                                echo '<option ' . ($examen_alumno->getCondicion() == $value ? 'selected' : '') . ' value="' . $value . '">' . $condicion . '</option>';
                                            }
                                            ?>
                                        </select>
                                    </td>
                                    <td><input type="checkbox" name="examen_alumno[<?php echo $examen_alumno->getId() ?>][ausente]" <?php echo $examen_alumno->getAusente() ? 'checked' : '' ?> /></td>
                                    <td><input type="checkbox" name="examen_alumno[<?php echo $examen_alumno->getId() ?>][pagado]" <?php echo $examen_alumno->getPago() ? 'checked' : '' ?> /></td>
                                </tr>
                            <?php endforeach ?>
                        </tbody>
                    </table>
                    <input type="submit" class="btn pull-right" value="Guardar Cambios" />
                    <input type="submit" class="btn pull-right" name="imprimir" value="Imprimir" style="margin-right: 10px;" />
                    <div class="clearfix"></div>
                </div>
            </form>
        </div>
    </div>
</div>